# -*- coding:utf-8 -*-
"""
该脚本用来创建显示的hud
"""
try:
    import maya.cmds as cmds
    import maya.mel as mel
except Exception as test_ERR:
    print('test')


def shotFocalLength():
    fl = cmds.getAttr('cameraShape1.focalLength')
    return '{}'.format(round(fl, 2))


def currentFrame():
    return cmds.currentTime(query=True)

def createHUD(shot_name,main_cameraShape):
    fps = int(mel.eval('currentTimeUnitToFPS'))
    cmds.headsUpDisplay('asset_shot_name', ao=1, section=1, block=2, blockSize='medium', label=shot_name,
                        labelFontSize='large')
    cmds.headsUpDisplay('frame', ao=1, command=currentFrame, section=8, block=1, blockAlignment='left',
                        blockSize='large', label='Frame', labelFontSize='large', attachToRefresh=True)

    cmds.headsUpDisplay('focal_length', ao=1,
                        command=lambda: '{}'.format(round(cmds.getAttr(main_cameraShape + '.focalLength'), 2)),
                        section=8, block=2, blockAlignment='left',
                        blockSize='large', label='FL', labelFontSize='large', attachToRefresh=True)

    cmds.headsUpDisplay('fps', ao=1, section=8, block=3, blockAlignment='left', blockSize='large',
                        label='FPS     {}'.format(fps), labelFontSize='large')


def clearHUD():
    cmds.headsUpDisplay('asset_shot_name', remove=1)
    cmds.headsUpDisplay('frame', remove=1)
    cmds.headsUpDisplay('focal_length', remove=1)
    cmds.headsUpDisplay('fps', remove=1)